package com.kfm.bootmp.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket docket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        docket
            .apiInfo(apiInfo())
            .groupName("kfm")
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.kfm.bootmp.controller"))
            .paths(PathSelectors.any())
            .build();
       return docket;
    }

    public ApiInfo apiInfo(){
        return new springfox.documentation.service.ApiInfo(
            "kfm的SwaggerAPI文档",
            "这是一个SwaggerAPI文档",
            "v1.0",
            "http://localhost:8080",
            new springfox.documentation.service.Contact("kfm", "http://localhost:8080", "kfm@localhost"),
            "Apache 2.0",
            "http://www.apache.org/licenses/LICENSE-2.0",
            java.util.Collections.emptyList()
        );
    }
}
